package controller;

import java.util.ArrayList;

import modele.Square;
import modele.World;

public abstract class Event {

	private ArrayList<Rule> rules;

	public Event(World w){
		rules = new ArrayList<Rule>();
	}
	
	public void addRule(Rule r){
		rules.add(r);
	}
	
	public void applyEvent(World w){
		for(Rule r : rules){
			r.prepareToEvolve();//setEvolvedSquareMap(w.cloneSquareMap());
			for(Square[] squares : r.getEvolvedSquareMap()){
				for(Square s : squares){
					s.getState().applyRule(r, s, w);					
				}
			}
		}
		
	}

	public ArrayList<Rule> getRules() {
		return rules;
	}

	public void setRules(ArrayList<Rule> rules) {
		this.rules = rules;
	}
}
